package com.sec.android.app.myfiles.feature.dlp;

import android.content.Context;

import com.sec.android.app.myfiles.info.AppFeatures;
import com.sec.android.app.myfiles.log.Log;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.util.SemFwWrapper;
import com.sec.android.app.myfiles.util.UiUtils;

import java.io.File;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.Map;
import java.util.zip.ZipEntry;
import java.util.zip.ZipException;

/**
 * Created by jaebae on 2016-04-22.
 */
public class DlpImp {
    private Context mContext;

    private Map<String, String> mDlpFiles = null;

    public DlpImp(Context context, Object dlpManager) {
        mContext = context;
    }

    public static Object createDlpManager(Context context) {
        Object ret = null;
        return ret;
    }

    private static boolean isDlpIncluded() {
        boolean bRet = true;
        try {
            Class.forName("com.samsung.android.knox.dlp.SemDlpManager");
        } catch (ClassNotFoundException e) {
            Log.d("isDlpIncluded", "DLP is not supported");
            bRet = false;
        }
        return bRet;
    }


    public void setZipFileExpiry(File targetFile) {

    }

    public void copyFileExpiry(FileRecord srcFile, FileRecord targetFile) {

    }

    private long getAdminExpiryTime() {
        long expiry = -1;
        return expiry;
    }

    public void restoreZipFileExpiry(FileRecord src) {

    }

    public void putDLPFilesMap(File dstFile, String fileName) {
        Log.d(this, "putDLPFilesMap new file[" + dstFile.getAbsolutePath() + "] old filename[" + fileName + "]");

        if (mDlpFiles == null) {
            mDlpFiles = new HashMap<>();
        }
        mDlpFiles.put(dstFile.getAbsolutePath(), fileName);

    }

    public String getExpiryTimeInfo(FileRecord record) {
        String ret = null;
        long expiryTime = getExpiryTimeInLong(record);
        if (expiryTime != -1) {
            ret = UiUtils.makeTimeString(mContext, expiryTime * 1000L);
        }
        return ret;
    }

    public long getExpiryTimeInLong(FileRecord record) {
        return -1;
    }

    public boolean isDlpFile(FileRecord record) {
        return false;
    }

    public void setExtraToZipEntry(ZipEntry zipEntry, String path) {
    }
}
